/*
 * Copyright 2010 Michael Nitsche
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package de.mnit.basis.sys.version;

import de.mnit.basis.daten.typ.zeit.S_Zeitpunkt;
import de.mnit.basis.fehler.Fehler;

/**
 * @author Michael Nitsche
 * 22.08.2008	Erstellt
 *
 * Pre-Alpha / Alpha / Beta / RC:
 * 0.6 Alpha 5		> 0.6.5
 * 0.7 Beta 9.1		> 0.7.9.1
 *
 * Release:
 * 1.3
 * 1.3.5
 * 1.4.6.2
 *
 * TODO Beim Release ist noch unklar, ob nur ein oder 2 zusätzliche Zahlen benötigt werden. Und ob artnr hier Sinn macht!
 *
 */
public class VersionsInfo {

	public final Integer		major;
	public final Integer		minor;
	public final VERSIONSART	art;
	public final Integer     	artnr; // 1 bis ...
	public final Integer     	fixnr; // 0 bis ...
	public final Long        	build;
	public final S_Zeitpunkt 	zeit;


	public static VersionsInfo neu(int major, int minor, VERSIONSART art, int artnr) {
		return new VersionsInfo(major, minor, art, artnr, 0);
	}

	public static VersionsInfo neu(int major, int minor, VERSIONSART art, int artnr, int fixnr) {
		return new VersionsInfo(major, minor, art, artnr, fixnr);
	}

	public static VersionsInfo neu(int major, int minor, VERSIONSART art, int artnr, int fixnr, long build, S_Zeitpunkt zeit) {
		return new VersionsInfo(major, minor, art, artnr, fixnr, build, zeit);
	}


	public VersionsInfo(int major, int minor, VERSIONSART art, int artnr, int fixnr) {
		this(major, minor, art, artnr, fixnr, null, null);
	}

	public VersionsInfo(int major, int minor, VERSIONSART art, int artnr, int fixnr, Long build, S_Zeitpunkt zeit) {
		Fehler.zahl.wenn_ZuKlein(1, artnr);
		Fehler.zahl.wenn_ZuKlein(0, fixnr);
		this.major=major;
		this.minor=minor;
		this.art=art;
		this.artnr=artnr;
		this.fixnr=fixnr;
		this.build=build;
		this.zeit=zeit;
	}


	public String toString() { //TODO FixNr muss hier noch überall rein, bzw. angepasst werden!!!!
		return iZuText(true);
	}

	public String zuText() {
		return toString();
	}

	public String zuText_BuildDatum() {
		return build+" - "+zeit.gDatum();
	}

	public String zuTextKurz() { //TODO FixNr muss hier noch überall rein, bzw. angepasst werden!!!!
		return iZuText(false);
	}

	private String iZuText(boolean lang) {
		String erg=major+"."+minor;
		erg+=" ";
		if(art!=VERSIONSART.RELEASE) erg+=art.text+artnr+(fixnr==0 ? "" : "."+fixnr);
//		else
		if(lang)
			erg+=" (Build:"+build+" - "+zeit+")";
		return erg;
	}
}
